package com.example.tt_bells_v02;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class ActivityDeleteBell extends Activity implements OnClickListener{

	TextView 	inform_text;
	Button		button_delete;
	Button		button_cancel;

	//int			call_idx = 999;
	boolean			is_several_days = false;
	int				edit_type = BellInfo.EDIT_BELL;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_delete_bell);
		
		inform_text = (TextView)findViewById(R.id.inform_text);
		
		button_delete = (Button)findViewById(R.id.button_delete);
		button_delete.setOnClickListener(this);
		button_cancel = (Button)findViewById(R.id.button_cancel);
		button_cancel.setOnClickListener(this);
		
		Intent calling = getIntent();
		edit_type = (int) calling.getIntExtra("edit_type", BellInfo.EDIT_BELL);
		switch (edit_type) {
			case BellInfo.EDIT_MONTH: {
				inform_text.setText("Do you really want to delete all bells of this month?");
			break; }
			case BellInfo.EDIT_DAY: {
				inform_text.setText("Do you really want to delete all bells of this day?");
			break; }
			case BellInfo.EDIT_TEMPLATE: {
				inform_text.setText("Do you really want to delete this template?");
			break; }
			default: {
				inform_text.setText("Do you really want to delete this bell?");
				is_several_days = (boolean) calling.getBooleanExtra("several_days", false);
				if (is_several_days) inform_text.append("\nIt affects more than one day!");
			break; }
		}
	}

	@Override
	public void onClick(View v) {
		Intent aaa = new Intent();
		switch (v.getId()) {
			case R.id.button_delete: {
				aaa.putExtra("delete", true);
			break; }
			case R.id.button_cancel: {
				aaa.putExtra("delete", false);
			break; }
		}
		aaa.putExtra("edit_type", edit_type);
		setResult(RESULT_OK,aaa);
		finish();
	}
}
